<?php 
include_once dirname(__FILE__)."/db.class.php" ;
 class aa_partenaire{
		 protected $_result;
		 protected $_cnn;
		 protected $_email;
		 protected $_nom;
		 protected $_prenom;
		 protected $_tel;
		 protected $_grade;
		 protected $_specialite;
		 //protected $_id_universite;
		 protected $_id_ue;
		 protected $_id_coconcepteur;
		 protected $_Adresse;
		 protected $_Ville;
		 protected $_CodePostal;
		 protected $_NumMobile;
		 protected $_NumTelephone;
		 protected $_NumFax;
		 protected $_Mail;
		 protected $_WebSite;
		 public function get_name_table(){ return "aa_partenaire";}
		 public function get_name_email(){ return "email";}
		 public function get_name_nom(){ return "nom";}
		 public function get_name_prenom(){ return "prenom";}
		 public function get_name_tel(){ return "tel";}
		 public function get_name_grade(){ return "grade";}
		 public function get_name_specialite(){ return "specialite";}
		 //public function get_name_id_universite(){ return "id_universite";}
		 public function get_name_id_ue(){ return "id_ue";}
		 public function get_name_id_coconcepteur(){ return "id_coconcepteur";}
		 public function get_name_Adresse(){ return "Adresse";}
		 public function get_name_Ville(){ return "Ville";}
		 public function get_name_CodePostal(){ return "CodePostal";}
		 public function get_name_NumMobile(){ return "NumMobile";}
		 public function get_name_NumTelephone(){ return "NumTelephone";}
		 public function get_name_NumFax(){ return "NumFax";}
		 public function get_name_Mail(){ return "Mail";}
		 public function get_name_WebSite(){ return "WebSite";}
		 public function set_email($parametre){  $this->_email=$parametre;}	
		 public function set_nom($parametre){  $this->_nom=$parametre;}	
		 public function set_prenom($parametre){  $this->_prenom=$parametre;}	
		 public function set_tel($parametre){  $this->_tel=$parametre;}	
		 public function set_grade($parametre){  $this->_grade=$parametre;}	
		 public function set_specialite($parametre){  $this->_specialite=$parametre;}	
	//	 public function set_id_universite($parametre){  $this->_id_universite=$parametre;}	
		 public function set_id_ue($parametre){  $this->_id_ue=$parametre;}	
		 public function set_id_coconcepteur($parametre){  $this->_id_coconcepteur=$parametre;}	
		 public function set_Adresse($parametre){  $this->_Adresse=$parametre;}	
		 public function set_Ville($parametre){  $this->_Ville=$parametre;}	
		 public function set_CodePostal($parametre){  $this->_CodePostal=$parametre;}	
		 public function set_NumMobile($parametre){  $this->_NumMobile=$parametre;}	
		 public function set_NumTelephone($parametre){  $this->_NumTelephone=$parametre;}	
		 public function set_NumFax($parametre){  $this->_NumFax=$parametre;}	
		 public function set_Mail($parametre){  $this->_Mail=$parametre;}	
		 public function set_WebSite($parametre){  $this->_WebSite=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_email(){ return $this->_email;}
		 public function get_nom(){ return $this->_nom;}
		 public function get_prenom(){ return $this->_prenom;}
		 public function get_tel(){ return $this->_tel;}
		 public function get_grade(){ return $this->_grade;}
		 public function get_specialite(){ return $this->_specialite;}
	//	 public function get_id_universite(){ return $this->_id_universite;}
		 public function get_id_ue(){ return $this->_id_ue;}
		 public function get_id_coconcepteur(){ return $this->_id_coconcepteur;}
		 public function get_Adresse(){ return $this->_Adresse;}
		 public function get_Ville(){ return $this->_Ville;}
		 public function get_CodePostal(){ return $this->_CodePostal;}
		 public function get_NumMobile(){ return $this->_NumMobile;}
		 public function get_NumTelephone(){ return $this->_NumTelephone;}
		 public function get_NumFax(){ return $this->_NumFax;}
		 public function get_Mail(){ return $this->_Mail;}
		 public function get_WebSite(){ return $this->_WebSite;}
public function __construct(){

		 	$this->_cnn=new Db();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 aa_partenaire(
			email,
			nom,
			prenom,
			tel,
			grade,
			specialite,
			id_ue,
			Adresse,
			Ville,
			CodePostal,
			NumMobile,
			NumTelephone,
			NumFax,
			Mail,
			WebSite)
 VALUES(
			'".$this->_email."',
			'".$this->_nom."',
			'".$this->_prenom."',
			'".$this->_tel."',
			'".$this->_grade."',
			'".$this->_specialite."','".$this->_id_ue."','".$this->_Adresse."',
			'".$this->_Ville."',
			'".$this->_CodePostal."',
			'".$this->_NumMobile."',
			'".$this->_NumTelephone."',
			'".$this->_NumFax."',
			'".$this->_Mail."',
			'".$this->_WebSite."')";
echo $sql;

$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
$this->_cnn->disconnect();
 if(!$this->_result){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_email)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
email='".$this->_email."'";
}
if(!empty($this->_nom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
nom='".$this->_nom."'";
}
if(!empty($this->_prenom)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
prenom='".$this->_prenom."'";
}
if(!empty($this->_tel)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
tel='".$this->_tel."'";
}
if(!empty($this->_grade)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
grade='".$this->_grade."'";
}
if(!empty($this->_specialite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
specialite='".$this->_specialite."'";
}

if(!empty($this->_id_ue)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
id_ue='".$this->_id_ue."'";
}
if(!empty($this->_Adresse)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Adresse='".$this->_Adresse."'";
}
if(!empty($this->_Ville)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Ville='".$this->_Ville."'";
}
if(!empty($this->_CodePostal)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
CodePostal='".$this->_CodePostal."'";
}
if(!empty($this->_NumMobile)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumMobile='".$this->_NumMobile."'";
}
if(!empty($this->_NumTelephone)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumTelephone='".$this->_NumTelephone."'";
}
if(!empty($this->_NumFax)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
NumFax='".$this->_NumFax."'";
}
if(!empty($this->_Mail)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
Mail='".$this->_Mail."'";
}
if(!empty($this->_WebSite)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
WebSite='".$this->_WebSite."'";
}
$sql="UPDATE 
aa_partenaire SET 
 ".$sql."
								WHERE 1=1  AND id_coconcepteur ='".$this->_id_coconcepteur."'";

$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
 $this->_cnn->disconnect();
 
 if(!$this->_result){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
aa_partenaire 
 
									WHERE 1=1  AND id_coconcepteur ='".$this->_id_coconcepteur."'";

$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
 $this->_cnn->disconnect();
 
 if(!$this->_result){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function TRANCATE(){

 $sql="TRUNCATE TABLE aa_partenaire ";

$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
 $this->_cnn->disconnect();
 
 if(!$this->_result){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		email,
		nom,
		prenom,
		tel,
		grade,
		specialite,
		
		id_ue,
		id_coconcepteur,
		Adresse,
		Ville,
		CodePostal,
		NumMobile,
		NumTelephone,
		NumFax,
		Mail,
		WebSite
 FROM 
 aa_partenaire";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}

$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
 $this->_cnn->disconnect();
 
 if(!$this->_result){return $this->_cnn->get_erreurmsg();}else{return 'success';}
}

 public function countRowInTable($constraint="")
{

$sql=" SELECT 
  COUNT(*) AS total 
 FROM 
 aa_partenaire ";
	$this->_cnn->connect();
$this->_result=$this->_cnn->query($sql);
 $this->_cnn->disconnect();
$donnees_total=mysql_fetch_assoc($this->_result);
return $donnees_total['total'];
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_email=$row->email;
		$this->_nom=$row->nom;
		$this->_prenom=$row->prenom;
		$this->_tel=$row->tel;
		$this->_grade=$row->grade;
		$this->_specialite=$row->specialite;
		
		$this->_id_ue=$row->id_ue;
		$this->_id_coconcepteur=$row->id_coconcepteur;
		$this->_Adresse=$row->Adresse;
		$this->_Ville=$row->Ville;
		$this->_CodePostal=$row->CodePostal;
		$this->_NumMobile=$row->NumMobile;
		$this->_NumTelephone=$row->NumTelephone;
		$this->_NumFax=$row->NumFax;
		$this->_Mail=$row->Mail;
		$this->_WebSite=$row->WebSite;
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>